﻿namespace YAPACS.RisServer.Services.ECharts;

/// <summary>
/// 坐标轴
/// </summary>
public class Axis
{
    /// <summary>
    /// 坐标轴类型
    /// time:时间
    /// value:值
    /// </summary>
    public string Type { get; set; }

    /// <summary>
    /// 名称
    /// </summary>
    public string Name { get; set; }

    /// <summary>
    /// 轴线
    /// </summary>
    public object AxisLine { get; set; }

    /// <summary>
    /// 刻度线
    /// length: 长度
    /// lineStyle: 线条样式 {type:'dashed'}
    /// </summary>
    public object AxisTick { get; set; }


    /// <summary>
    /// 轴线标签
    /// formatter:字符串模板
    /// align:对齐方式
    /// </summary>
    public object AxisLabel { get; set; }

    /// <summary>
    /// 获取Schema
    /// </summary>
    /// <returns></returns>
    public Dictionary<string, object> GetSchema()
    {
        Dictionary<string, object> schema = new();

        //轴类型
        if (!string.IsNullOrEmpty(Type))
        {
            schema.Add("type", Type);
        }

        if (!string.IsNullOrEmpty(Name))
        {
            schema.Add("name", Name);
        }

        //轴线配置
        if (AxisLine != null)
        {
            schema.Add("axisLine", AxisLine);
        }

        if (AxisLabel != null)
        {
            schema.Add("axisLabel", AxisLabel);
        }


        //刻度线
        if (AxisTick != null)
        {
            schema.Add("axisTick", AxisTick);
        }

        return schema;
    }
}
